package com.xiaotu.dao.pgsql;

import com.xiaotu.entity.DirectorWorksModel;
import com.xiaotu.entity.ScreenwriterWorksModel;
import com.xiaotu.entity.TvActorsModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * @author zhangxiao
 * @create 2021-09-23 11:19
 */
public interface PgsqlStarWorksMapper {

    @Select("<script>" +
            " SELECT  " +
            "  tvactorid,  " +
            "  starid,  " +
            "  starname,  " +
            "  tvid,  " +
            "  tvname,  " +
            "  actrole,  " +
            "  worktype,  " +
            "  collecttime,  " +
            "  actorder,  " +
            "  roleintroduction,  " +
            "  array_to_string(rolelabel, ',') rolelabel,  " +
            "  episode_count,  " +
            "  start_time,  " +
            "  end_time   " +
            "FROM  " +
            "  basicinfo.tab_tv_actors_to_tencent ORDER BY tvactorid::BIGINT limit #{pageSize} offset #{pageNum}*#{pageSize} " +
            "</script>")
    List<TvActorsModel> getTvActors(@Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize);

    @Select("<script>" +
            " SELECT " +
            " directorworksid, " +
            " starid, " +
            " starname, " +
            " tvname, " +
            " showdate, " +
            " actrole, " +
            " array_to_string( tvdirector, ',' ) tvdirector, " +
            " array_to_string( mainactors, ',' ) mainactors, " +
            " array_to_string( cooactors, ',' ) cooactors, " +
            " worktype, " +
            " collecttime, " +
            " tvid, " +
            " dirorder, " +
            " episode_count, " +
            " start_time, " +
            " end_time  " +
            "FROM " +
            " basicinfo.tab_director_works_to_tencent ORDER BY directorworksid::BIGINT limit #{pageSize} offset #{pageNum}*#{pageSize} " +
            "</script>")
    List<DirectorWorksModel> getDirectorWorks(@Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize);

    @Select("<script>" +
            " SELECT " +
            " screenwriterworksid, " +
            " starid, " +
            " starname, " +
            " tvname, " +
            " showdate, " +
            " actrole, " +
            " array_to_string( tvdirector, ',' ) tvdirector, " +
            " array_to_string( mainactors, ',' ) mainactors, " +
            " array_to_string( cooactors, ',' ) cooactors, " +
            " worktype, " +
            " collecttime, " +
            " tvid, " +
            " episode_count, " +
            " start_time, " +
            " end_time  " +
            "FROM " +
            " basicinfo.tab_screenwriter_works_to_tencent ORDER BY screenwriterworksid::BIGINT limit #{pageSize} offset #{pageNum}*#{pageSize} " +
            "</script>")
    List<ScreenwriterWorksModel> getScreenwriterWorks(@Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize);


}
